import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('BaseManager')
export abstract class BaseManager {
    
    /** 管理器名称 */
    abstract managerName: string

    /** 初始化执行 */
    abstract init(): void
    
    /** 加载并输出报告 */
    construct() {
        try {
            this.log(0)
            this.init()
            this.log(1)
        } catch (res) {
            this.log(2)
            console.log(res)
        }
    }

    /**
     * 输出报告
     * @param state 0-开始加载 1-成功 2-失败
     */
    log(state: 0 | 1 | 2) {
        switch(state) {
            case 0: 
                console.log(this.managerName + ' 开始加载')
                break
            case 1: 
                console.log(this.managerName + ' 加载成功')
                break
            case 2:
                console.log(this.managerName + ' 加载失败')
                break
        }
    }
}


